class ContactosController < ApplicationController
	layout 'proveedores'
  # GET /contactos
  # GET /contactos.xml
  def index
    @contactos = Contacto.find(:all)

    respond_to do |format|
      format.html # index.rhtml
      format.xml  { render :xml => @contactos.to_xml }
    end
  end

  # GET /contactos/1
  # GET /contactos/1.xml
  def show
    @contacto = Contacto.find(params[:id])

    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @contacto.to_xml }
    end
  end

  # GET /contactos/new
  def new
    @contacto = Contacto.new(:proveedor_id => params[:proveedor_id])
  end

  # GET /contactos/1;edit
  def edit
    @contacto = Contacto.find(params[:id])
  end

  # POST /contactos
  # POST /contactos.xml
  def create
    @contacto = Contacto.new(params[:contacto])
    @contacto.proveedor_id = params[:proveedor_id]

    respond_to do |format|
      if @contacto.save
        flash[:notice] = 'Contacto was successfully created.'
        format.html { redirect_to proveedor_url(params[:proveedor_id]) }
        format.xml  { head :created, :location => contacto_url(@contacto) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @contacto.errors.to_xml }
      end
    end
  end

  # PUT /contactos/1
  # PUT /contactos/1.xml
  def update
    @contacto = Contacto.find(params[:id])

    respond_to do |format|
      if @contacto.update_attributes(params[:contacto])
        flash[:notice] = 'Contacto was successfully updated.'
        format.html { redirect_to proveedor_url(params[:proveedor_id]) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @contacto.errors.to_xml }
      end
    end
  end

  # DELETE /contactos/1
  # DELETE /contactos/1.xml
  def destroy
    @contacto = Contacto.find(params[:id])
    @contacto.destroy

    respond_to do |format|
      format.html { redirect_to proveedor_url(params[:proveedor_id]) }
      format.xml  { head :ok }
    end
  end
end
